package org.fire.net;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;

public class SocketServer
{
	private ServerBootstrap bootstrap = new ServerBootstrap();

	public void init() throws InterruptedException
	{
		EventLoopGroup bossGroup = new NioEventLoopGroup();
		EventLoopGroup workerGroup = new NioEventLoopGroup();
		bootstrap.group(bossGroup, workerGroup);
		bootstrap.channel(NioServerSocketChannel.class);
		bootstrap.childHandler(new DefaultChannelInitializer());
		bootstrap.option(ChannelOption.SO_BACKLOG, 128);
		bootstrap.option(ChannelOption.SO_LINGER, 0);
		bootstrap.option(ChannelOption.TCP_NODELAY, true);
		ChannelFuture f = bootstrap.bind(9999);
		f.sync();
		System.out.println("++++++++++++++++++++++");
		System.out.println("Server is now listening @ " + 9999);
		System.out.println("++++++++++++++++++++++");
	}
}
